using System;
using OneDayModel.Interfaces;
using OneDayModel.Model;
using OneDayModel.PresentationLogic;
using OneDayModel.Tests.Mocks;

namespace OneDayModel.Tests.Fits.UIUsers
{
    public class UserLoginUser : IUserLoginUI
    {
        private string userAlias;
        private string userPassword;

        public IUser user;
        private string shownPage;

        public event EventHandler<UserLoginArgs> onUserLogin;

        public UserLoginUser()
        {
            MockRepository repository = new MockRepository();
            new UserLoginUILogic(this, new UserLoginModel(repository, repository));
        }

        public string ShownPage
        {
            get { return shownPage; }
        }

        public void SetAlias(string alias)
        {
            userAlias = alias;
        }

        public void SetPassword(string password)
        {
            userPassword = password;
        }

        public void ShowUserStartupPage(IUser user)
        {
            shownPage = "User Startup Page";
            this.user = user;
        }

        public void LoginUser()
        {
            if (onUserLogin!=null)
                onUserLogin(this, new UserLoginArgs(userAlias, userPassword));
        }

        public void ShowStillWaitingForConfirmation(IUser user)
        {
            shownPage = "Still Waiting For Confirmation";
            this.user = user;
        }

        public void ShowAccountBannedPage(IUser user)
        {
            shownPage =  "Account Banned";
            this.user = user;
        }

        #region IUserLoginUI Members

        public void ShowUserNotFound()
        {
            shownPage = "User Not Found";
        }

        public void ShowInvalidPassword()
        {
            shownPage = "Invalid Password";
        }

        public void AliasIsEmpty()
        {
            shownPage = "Alias is empty";
        }

        #endregion
    }
}